﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Threading.Tasks;

namespace MathGraphics
{
    /// <summary>
    /// 二位向量
    /// </summary>
    public struct Vector2
    {
        public int X { get; set; }
        public int Y { get; set; }
        
        public Vector2(int x , int y)
        {
            X = x;
            Y = y;
        }

        public override bool Equals(object obj)
        {
            return ((Vector2)obj) == this;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
        public static Vector2 operator + (Vector2 left ,Vector2 right)
        {
            return new Vector2(left.X + right.X, left.Y + right.Y);
        }

        [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
        public static Vector2 operator -(Vector2 left, Vector2 right)
        {
            return new Vector2(left.X - right.X, left.Y - right.Y);
        }

        public static bool operator ==(Vector2 left, Vector2 right)
        {
            return !(left != right);
        }

        [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
        public static bool operator !=(Vector2 left, Vector2 right)
        {
            return !(left.X == right.X && left.Y == right.Y);
        }
    }
}
